#define _CRT_SECURE_NO_WARNINGS 1
#include"SList.h"


void Test1()
{
	SLTNote* s1 = (SLTNote*)malloc(sizeof(SLTNote));
	assert(s1);

	SLTNote* s2 = (SLTNote*)malloc(sizeof(SLTNote));
	assert(s2);

	SLTNote* s3 = (SLTNote*)malloc(sizeof(SLTNote));
	assert(s3);

	SLTNote* s4 = (SLTNote*)malloc(sizeof(SLTNote));
	assert(s4);

	s1->data = 1;
	s2->data = 2;
	s3->data = 3;
	s4->data = 4;

	s1->next = s2;
	s2->next = s3;
	s3->next = s4;
	s4->next = NULL;

	SLTNote* plist = s1;
	SListPrint(plist);
	SListPushBack(&plist, 5);
	SListPushBack(&plist, 5);
	SListPushBack(&plist, 5);
	SListPushBack(&plist, 5);
	SListPushBack(&plist, 5);
	SListPrint(plist);
}

void Test2()
{
	SLTNote* plist = NULL;
	SListPushBack(&plist, 4);
	SListPushBack(&plist, 4);
	SListPushBack(&plist, 4);
	SListPushBack(&plist, 4);
	SListPushBack(&plist, 4);
	SListPrint(plist);

	SListPushFront(&plist, 0);
	SListPopFront(&plist);
	SListPrint(plist);
}


void Test3()
{
	SLTNote* plist = NULL;
	SListPushBack(&plist, 4);
	SListPushBack(&plist, 4);
	SListPushBack(&plist, 4);
	SListPushBack(&plist, 4);
	SListPushBack(&plist, 4);
	SListPrint(plist);

	SListPopBack(&plist);
	SListPrint(plist);
}

void Test4()
{
	SLTNote* plist = NULL;
	SListPushBack(&plist, 1);
	SListPushBack(&plist, 2);
	SListPushBack(&plist, 3);
	SListPushBack(&plist, 4);
	SListPushBack(&plist, 5);
	SListPrint(plist);

	SLTNote* ret= SListFind(plist, 4);
	if (ret)
	{
		ret->data = 40;
	}
	SListPrint(plist);
}

void Test5()
{
	SLTNote* plist = NULL;
	SListPushBack(&plist, 1);
	SListPushBack(&plist, 2);
	SListPushBack(&plist, 3);
	SListPushBack(&plist, 4);
	SListPushBack(&plist, 5);
	SListPrint(plist);

	
	SLTNote* pos = SListFind(plist, 4);
	if (pos)
	{
		SListInsert(&plist, pos, 40);
	}
	if (pos)
	{
		SListErase(&plist,pos);
	}
	SListPrint(plist);
}
int main()
{
	Test5();
	return 0;
}